#ifndef _SERIAL_H_INCLUDED
#define _SERIAL_H_INCLUDED

/*------------------------------------------------------
    Include files
 ------------------------------------------------------*/
#include "stm32f10x.h"
#include "os_cpu.h"

class CSerial{

public:

			  
	
	//Ctor
	CSerial(USART_TypeDef* USARTx, INT8U Prio, INT32U BufSize, INT32U BaudRate, BOOLEAN RemapEn);

	//Set and get Buffer size
	void SetBufSize(INT16U BufSize) {mBufSize = BufSize;}
	INT16U GetBufSize(void) {return mBufSize;}

	USART_TypeDef* GetUSARTPointer(void){return mpUSARTx;}

	//Push a char to the transmit buffer
	char SendChar(char ch);

	//Push a string to the transmit buffer
	void SendString(char* pStr);
	
	//Push a array to the transmit buffer
	void SendArray(char* pArray, INT16U Len);

	//Pop a char from the recieve buffer
	char GetChar();

	//ISR
	void ISR(void);

	
protected:
	USART_TypeDef* mpUSARTx;
	char* mpTxBuffer;
	char* mpRxBuffer;
	INT16U mBufSize;
	INT16U mTxBufHead;
	INT16U mTxBufTail;
	INT16U mRxBufHead;
	INT16U mRxBufTail;
	
};

extern "C" void CSerial_ISR(CSerial &Serialx);


#endif // _SERIAL_H_INCLUDED
